﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ICAM.Model;

namespace ICAM.DataLayer
{
    public class DataService
    {
        public User GetLoginUser()
        {
            User user = new User();
            user.UserID = "1";
            user.UserName = "lidaqiang";
            user.LoginName = "李大强";
            user.PhoneNumber = "16538839000";
            user.Photo = "";  //图片地址，这里配置资源路径
            user.L1AlarmDealNum = 21;
            user.L2AlarmDealNum = 35;
            user.L3AlarmDealNum = 47;
            user.L4AlarmDealNum = 0;
            user.AlarmDealNum = 103;
            return user;
        }

        public List<AlarmStatistics> GetAlarmStatistics()
        {
            List<AlarmStatistics> lstAlarmStatistics = new List<AlarmStatistics>();

            AlarmStatistics alarmStatistics = new AlarmStatistics();
            alarmStatistics.AlarmLever = "1";
            alarmStatistics.UnDealNum = 4;
            alarmStatistics.DealNum = 7;
            alarmStatistics.IgnoreNum =10;
            alarmStatistics.SumNum = 21;
            lstAlarmStatistics.Add(alarmStatistics);

            alarmStatistics = new AlarmStatistics();
            alarmStatistics.AlarmLever = "2";
            alarmStatistics.UnDealNum = 11;
            alarmStatistics.DealNum = 12;
            alarmStatistics.IgnoreNum = 12;
            alarmStatistics.SumNum = 35;
            lstAlarmStatistics.Add(alarmStatistics);

            alarmStatistics = new AlarmStatistics();
            alarmStatistics.AlarmLever = "3";
            alarmStatistics.UnDealNum = 8;
            alarmStatistics.DealNum = 24;
            alarmStatistics.IgnoreNum = 15;
            alarmStatistics.SumNum = 47;
            lstAlarmStatistics.Add(alarmStatistics);

            return lstAlarmStatistics;
        }


        /// <summary>
        /// 获取告警位置的Top N 数据，最多5条记录
        /// </summary>
        /// <returns></returns>
        public List<TopAlarmStatistics> GetAlarmLocation()
        {
            List<TopAlarmStatistics> lstAlarmLocation = new List<TopAlarmStatistics>();

            TopAlarmStatistics topAlarmStatistics = new TopAlarmStatistics();
            topAlarmStatistics.OrderNum = 1;
            topAlarmStatistics.AlarmGroupName = "小区东门";
            topAlarmStatistics.AlarmNum = 35;
            topAlarmStatistics.ContainAlarmLever_1 = 1;
            lstAlarmLocation.Add(topAlarmStatistics);

            topAlarmStatistics = new TopAlarmStatistics();
            topAlarmStatistics.OrderNum = 2;
            topAlarmStatistics.AlarmGroupName = "B幢2单元";
            topAlarmStatistics.AlarmNum = 23;
            topAlarmStatistics.ContainAlarmLever_1 = 0;
            lstAlarmLocation.Add(topAlarmStatistics);

            topAlarmStatistics = new TopAlarmStatistics();
            topAlarmStatistics.OrderNum = 3;
            topAlarmStatistics.AlarmGroupName = "小区南门";
            topAlarmStatistics.AlarmNum = 10;
            topAlarmStatistics.ContainAlarmLever_1 = 0;
            lstAlarmLocation.Add(topAlarmStatistics);

            return lstAlarmLocation;

        }


        /// <summary>
        /// 获取告警分布，最多5条记录
        /// </summary>
        /// <returns></returns>
        public List<TopAlarmStatistics> GetAlarmDistribution()
        {
            List<TopAlarmStatistics> lstAlarmDistribution = new List<TopAlarmStatistics>();

            TopAlarmStatistics topAlarmStatistics = new TopAlarmStatistics();
            topAlarmStatistics.OrderNum = 1;
            topAlarmStatistics.AlarmGroupName = "业主家人3天未出小区";
            topAlarmStatistics.AlarmNum = 23;
            topAlarmStatistics.ContainAlarmLever_1 = 0;
            lstAlarmDistribution.Add(topAlarmStatistics);

            topAlarmStatistics = new TopAlarmStatistics();
            topAlarmStatistics.OrderNum = 2;
            topAlarmStatistics.AlarmGroupName = "外卖人员长时间未出小区";
            topAlarmStatistics.AlarmNum = 10;
            topAlarmStatistics.ContainAlarmLever_1 = 0;
            lstAlarmDistribution.Add(topAlarmStatistics);

            topAlarmStatistics = new TopAlarmStatistics();
            topAlarmStatistics.OrderNum = 3;
            topAlarmStatistics.AlarmGroupName = "陌生人逗留";
            topAlarmStatistics.AlarmNum = 9;
            topAlarmStatistics.ContainAlarmLever_1 = 0;
            lstAlarmDistribution.Add(topAlarmStatistics);

            topAlarmStatistics = new TopAlarmStatistics();
            topAlarmStatistics.OrderNum = 4;
            topAlarmStatistics.AlarmGroupName = "黑名单人员出没";
            topAlarmStatistics.AlarmNum = 2;
            topAlarmStatistics.ContainAlarmLever_1 = 0;
            lstAlarmDistribution.Add(topAlarmStatistics);

            return lstAlarmDistribution;

        }

        /// <summary>
        /// 获取告警列表,全部告警也可以使用，告警推送可以获取一条
        /// </summary>
        /// <returns></returns>
        public List<AlarmInfo> GetAlarmInfo(int AlarmNum)
        {

            List<AlarmInfo> lstAlarmInfo = new List<AlarmInfo>();

            for (int i = 0; i < AlarmNum; i++)
            {
                AlarmInfo alarmInfo = new AlarmInfo();
                alarmInfo.AlarmID = "dm23456677";
                ///告警类型编号
                alarmInfo.AlarmTypeCode = i.ToString();  //
                DateTime time = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);
                string timeStr = time.ToString("yyyy年MM月dd日");
                switch (i % 4)
                {
                    case 0:
                        ///告警类型名称
                        alarmInfo.AlarmTypeName = "快递人员长时间未出小区";
                        ///告警级别
                        alarmInfo.AlarmLevel = (i % 3 + 1).ToString();

                        ///告警对象信息
                        alarmInfo.AlarmObjInfo = "快递人员";

                        ///告警处理状态
                        alarmInfo.AlarmDealStatus = i.ToString();
                        ///告警处理类型（忽略/处理）
                        alarmInfo.AlarmDealType = "未处理";
                        ///告警处理模板
                        alarmInfo.AlarmDealTempCode = "";
                        ///告警处理人
                        alarmInfo.AlarmDealPeople = "";
                        ///告警处理时间
                        alarmInfo.AlarmDealTime = "";
                        ///告警处理备注
                        alarmInfo.AlarmDealRemake = "";

                        ///告警描述
                        alarmInfo.AlarmDesc = "发现有一名快递人员长时间未出小区,请留意";
                        break;
                    case 1:

                        ///告警类型名称
                        alarmInfo.AlarmTypeName = "陌生人逗留";
                        ///告警级别
                        alarmInfo.AlarmLevel = (i % 3 + 1).ToString();

                        ///告警对象信息
                        alarmInfo.AlarmObjInfo = "陌生人";

                        ///告警处理状态
                        alarmInfo.AlarmDealStatus = i.ToString();
                        ///告警处理类型（忽略/处理）
                        alarmInfo.AlarmDealType = "已处理";
                        ///告警处理模板
                        alarmInfo.AlarmDealTempCode = "1";
                        ///告警处理人
                        alarmInfo.AlarmDealPeople = "李强";
                        ///告警处理时间
                        alarmInfo.AlarmDealTime = $"{timeStr} 22:30";//"2019年8月9日 22:30";
                                                                     ///告警处理备注
                        alarmInfo.AlarmDealRemake = "问题已现场核实处理";

                        ///告警描述
                        alarmInfo.AlarmDesc = "在凌晨3:00-4:00小区东门发现有陌生人逗留,请留意";
                        break;
                    case 2:
                        ///告警类型名称
                        alarmInfo.AlarmTypeName = "黑名单人员出没";
                        ///告警级别
                        alarmInfo.AlarmLevel = (i % 3 + 1).ToString();

                        ///告警对象信息
                        alarmInfo.AlarmObjInfo = "黑名单人员";

                        ///告警处理状态
                        alarmInfo.AlarmDealStatus = i.ToString();
                        ///告警处理类型（忽略/处理）
                        alarmInfo.AlarmDealType = "已升级";
                        ///告警处理模板
                        alarmInfo.AlarmDealTempCode = "2";
                        ///告警处理人
                        alarmInfo.AlarmDealPeople = "李强";
                        ///告警处理时间
                        alarmInfo.AlarmDealTime = $"{timeStr} 22:30";//"2019年8月9日 22:30";
                                                                     ///告警处理备注
                        alarmInfo.AlarmDealRemake = "问题已现场核实处理";

                        ///告警描述
                        alarmInfo.AlarmDesc = "黑名单人员在小区周围反复出现";
                        break;

                    case 3:
                        ///告警类型名称
                        alarmInfo.AlarmTypeName = "业主家人3天未出小区";
                        ///告警级别
                        alarmInfo.AlarmLevel = (i % 3 + 1).ToString();

                        ///告警对象信息
                        alarmInfo.AlarmObjInfo = "5栋2单元";

                        ///告警处理状态
                        alarmInfo.AlarmDealStatus = i.ToString();
                        ///告警处理类型（忽略/处理）
                        alarmInfo.AlarmDealType = "已上报";
                        ///告警处理模板
                        alarmInfo.AlarmDealTempCode = "2";
                        ///告警处理人
                        alarmInfo.AlarmDealPeople = "李强";
                        ///告警处理时间
                        alarmInfo.AlarmDealTime = $"{timeStr} 12:32";//"2019年8月9日 22:30";
                                                                     ///告警处理备注
                        alarmInfo.AlarmDealRemake = "业主发生急病，需要人员支持";

                        ///告警描述
                        alarmInfo.AlarmDesc = "发现5号楼2单元业主家人3天未出小区请留意,请留意";
                        break;
                }
                time = DateTime.Now;
                ///告警时间
                alarmInfo.AlarmTime = $"{timeStr} {(time.Hour - 1)}:{time.Minute}-{time.Hour}:{time.Minute}";//"2019年8月9日 03:00-04:00";
                                                                                                           ///告警小区
                alarmInfo.CommunityID = "1";
                ///告警发生地
                alarmInfo.Location = "小区东门";
                ///告警大图url
                alarmInfo.AlarmPhotoUrl = "pack://application:,,,/Resource/Images/test.png";
                ///告警最新图片url
                alarmInfo.AlarmLatestPhotoUrl = "pack://application:,,,/Resource/Images/test.png";
                //---------------------告警还原小图列表-------------------
                // public List<AlarmDetail.AlarmRestorationInfo> ListAlarmRestorationInfo =;
                //---------------------告警处理----------------------------
                alarmInfo.ListAlarmRestorationInfo = new List<AlarmDetail.AlarmRestorationInfo>();


                lstAlarmInfo.Add(alarmInfo);
            }


            return lstAlarmInfo;

        }

        public AlarmInfo GetAlarmRestorationInfo(AlarmInfo alarmInfo, int imageNum)
        {
            AlarmInfo tmpAlarmInfo = alarmInfo;

            //如果还没有初始图片
            string testImg = System.IO.Path.Combine(Environment.CurrentDirectory, "test1.png");
            if (tmpAlarmInfo.ListAlarmRestorationInfo.Count == 0)
            {
                for (int i = 0; i < imageNum; i++)
                {
                    AlarmDetail.AlarmRestorationInfo info = new AlarmDetail.AlarmRestorationInfo();
                    info.AlarmID = alarmInfo.AlarmID; //告警ID
                    info.PicOrder = i + 1;               //告警小图序号
                    info.Position = "小区东门";        //地点
                    info.PicUrl = testImg;                  //图片url
                    info.AlarmTime = "8月9日 03:00";  //时间

                    tmpAlarmInfo.ListAlarmRestorationInfo.Add(info);
                }
            }

            return tmpAlarmInfo;
        }

        public List<OperationLog> GetOperationLog(int LogNum)
        {
            List<OperationLog> list = new List<OperationLog>();
            for (int i = 0; i < LogNum; i++)
            {
                OperationLog log = new OperationLog();
                log.Id = i;
                log.OperateTime = "2020年3月9日 11::23";
                log.OperateUserName = "李强";
                log.PhoneNo = "13882088776";
                log.OperateType = "账号登录";
            }
            return list;
        }

        public List<HousingEstate> GetHousingEstate()
        {
            List<HousingEstate> lst = new List<HousingEstate>();

            HousingEstate housingEstate = new HousingEstate();
            housingEstate.HousingEstateID = 10;
            housingEstate.ParentHousingEstateID = 1;
            housingEstate.HousingEstateName = "东南区域";
            housingEstate.IsHousingEstate = 0;
            housingEstate.HousingEstateFullName = "";
            lst.Add(housingEstate);

            housingEstate = new HousingEstate();
            housingEstate.HousingEstateID = 11;
            housingEstate.ParentHousingEstateID = 1;
            housingEstate.HousingEstateName = "西南区域";
            housingEstate.IsHousingEstate = 0;
            housingEstate.HousingEstateFullName = "";
            lst.Add(housingEstate);

            housingEstate = new HousingEstate();
            housingEstate.HousingEstateID = 12;
            housingEstate.ParentHousingEstateID = 1;
            housingEstate.HousingEstateName = "西北区域";
            housingEstate.IsHousingEstate = 0;
            housingEstate.HousingEstateFullName = "";
            lst.Add(housingEstate);


            housingEstate = new HousingEstate();
            housingEstate.HousingEstateID = 101;
            housingEstate.ParentHousingEstateID = 10;
            housingEstate.HousingEstateName = "蓝光圣菲town城";
            housingEstate.IsHousingEstate = 1;
            housingEstate.HousingEstateFullName = "";
            lst.Add(housingEstate);

            housingEstate = new HousingEstate();
            housingEstate.HousingEstateID = 102;
            housingEstate.ParentHousingEstateID = 10;
            housingEstate.HousingEstateName = "蓝光锦绣城";
            housingEstate.IsHousingEstate = 1;
            housingEstate.HousingEstateFullName = "";
            lst.Add(housingEstate);

            housingEstate = new HousingEstate();
            housingEstate.HousingEstateID = 111;
            housingEstate.ParentHousingEstateID = 11;
            housingEstate.HousingEstateName = "蓝光COCO金沙";
            housingEstate.IsHousingEstate = 1;
            housingEstate.HousingEstateFullName = "";
            lst.Add(housingEstate);

            housingEstate = new HousingEstate();
            housingEstate.HousingEstateID = 112;
            housingEstate.ParentHousingEstateID = 11;
            housingEstate.HousingEstateName = "蓝光公园悦府";
            housingEstate.IsHousingEstate = 1;
            housingEstate.HousingEstateFullName = "";
            lst.Add(housingEstate);

            housingEstate = new HousingEstate();
            housingEstate.HousingEstateID = 113;
            housingEstate.ParentHousingEstateID = 11;
            housingEstate.HousingEstateName = "蓝光幸福满庭";
            housingEstate.IsHousingEstate = 1;
            housingEstate.HousingEstateFullName = "";
            lst.Add(housingEstate);

            housingEstate = new HousingEstate();
            housingEstate.HousingEstateID = 121;
            housingEstate.ParentHousingEstateID = 12;
            housingEstate.HousingEstateName = "蓝光COCO时代";
            housingEstate.IsHousingEstate = 1;
            housingEstate.HousingEstateFullName = "";
            lst.Add(housingEstate);

            housingEstate = new HousingEstate();
            housingEstate.HousingEstateID = 122;
            housingEstate.ParentHousingEstateID = 12;
            housingEstate.HousingEstateName = "蓝光香江国际";
            housingEstate.IsHousingEstate = 1;
            housingEstate.HousingEstateFullName = "";
            lst.Add(housingEstate);

            return lst;
        }


    }
}
